
<template>
    <div>
        <el-form :inline="true" :model="formInline" class="demo-form-inline" style="border-bottom:1px solid #ccc;">
            <!--法人名称-->
            <el-form-item :label="nowLangue.legalName" class="selectMB10">
                <el-select size="mini" clearable v-model="formInline.status" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(status,index) in statusList" :key="index" :label="status.label" :value="status.value"></el-option>
                </el-select>
            </el-form-item>
            <!--检验标准编码-->
            <el-form-item :label="nowLangue.inspectionStandardCoding" class="selectMB10">
                <el-input size="mini" v-model="formInline.materialName" :placeholder="nowLangue.pleaseImport+nowLangue.inspectionStandardCoding"></el-input>
            </el-form-item>
            <!--检验标准名称-->
            <el-form-item :label="nowLangue.inspectionStandardName" class="selectMB10">
                <el-select size="mini" clearable v-model="formInline.status" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(status,index) in statusList" :key="index" :label="status.label" :value="status.value"></el-option>
                </el-select>
            </el-form-item>
            <!--状态-->
            <el-form-item :label="nowLangue.status" class="selectMB10">
                <el-select size="mini" clearable v-model="formInline.status" :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(status,index) in statusList" :key="index" :label="status.label" :value="status.value"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item class="selectMB10">
                <el-button class="bolder outsideBtnBS selectAll" :disabled="selectDisabled" size="mini" type="danger" @click="queryClick()" v-text="nowLangue.query"></el-button>
            </el-form-item>
        </el-form>
        <!--表格-->
        <label class="default-label" v-text="nowLangue.inspectionStandardDetails"></label>
        <el-button class="bolder outsideBtnBS" :disabled="addDisabled" size="mini" type="danger" @click="handleAdd" v-text="nowLangue.create"></el-button>
        <el-table :data="autoExamData" border style="width: 100%;" v-loading.body="loading" :element-loading-text="nowLangue.loadDesperately">
            <el-table-column type="index" header-align="center" align="center" :label="nowLangue.sequence" width="40"></el-table-column>
            <!--操作-->
            <el-table-column :label="nowLangue.operate" header-align="center" align="center" width="100">
                <template scope="scope">
                    <button class="operationItem bolder" :disabled="forbiddenDisabled" v-if="scope.row.status" @click="handleStatus(scope.$index,scope.row)" v-text="nowLangue.forbidden"></button>
                    <button class="operationItem bolder" :disabled="enableDisabled" v-else @click="handleStatus(scope.$index,scope.row)" v-text="nowLangue.enable"></button>
                    <button class="operationItem disabled bolder" v-if="scope.row.status" v-text="nowLangue.update"></button>
                    <button class="operationItem bolder" v-else @click="handleUpdate(scope.$index,scope.row)" v-text="nowLangue.update"></button>
                </template>
            </el-table-column>
            <!--检验标准编码-->
            <el-table-column prop="" :label="nowLangue.inspectionStandardCoding" header-align="center" show-overflow-tooltip></el-table-column>
            <!--检验标准名称-->
            <el-table-column prop="" :label="nowLangue.inspectionStandardName" header-align="center"  show-overflow-tooltip></el-table-column>
            <!--适用范围-->
            <el-table-column prop="" :label="nowLangue.applicableScope" header-align="center"  show-overflow-tooltip></el-table-column>
            <!--法人名称-->
            <el-table-column prop="" :label="nowLangue.legalName" header-align="center"  show-overflow-tooltip></el-table-column>
            <!--状态-->
            <el-table-column prop="" :label="nowLangue.status" header-align="center"  show-overflow-tooltip></el-table-column>
            <!--创建人-->
            <el-table-column prop="" :label="nowLangue.founder" header-align="center"  show-overflow-tooltip></el-table-column>
            <!--创建时间-->
            <el-table-column prop="" :label="nowLangue.creationTime" header-align="center"  show-overflow-tooltip></el-table-column>
            <!--修改人-->
            <el-table-column prop="" :label="nowLangue.modifier" header-align="center"  show-overflow-tooltip></el-table-column>
            <!--最近修改时间-->
            <el-table-column prop="" :label="nowLangue.latestModificationTime" header-align="center"  show-overflow-tooltip></el-table-column>
        </el-table>
        <el-pagination v-if="isPaging"  @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="currentPage3" :current-page="pageIndex"  :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :page-count="totalPage" :total="totalNumber"></el-pagination>
        <!--新增弹窗-->
        <el-dialog :title="nowLangue.create+nowLangue.inspectionStandardName" :visible.sync="dialogAddVisible" size="tiny" :lock-scroll="false">
            <el-form :inline="true" :model="addAutoExamForm" class="demo-form-inline label-minW95" style="border-bottom:1px solid #ccc;" ref="addAutoExamForm">
                <!--法人名称-->
                <el-form-item :label="nowLangue.legalName" prop="subClassCode" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-select size="mini" clearable v-model="addAutoExamForm.status" :placeholder="nowLangue.pleaseSelect">
                        <el-option v-for="(status,index) in statusList" :key="index" :label="status.label" :value="status.value"></el-option>
                    </el-select>
                </el-form-item>
                <!--检验标准编码-->
                <el-form-item :label="nowLangue.inspectionStandardCoding" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input v-model="addAutoExamForm.code" :placeholder="nowLangue.pleaseImport"></el-input>
                </el-form-item>
                <!--检验标准名称-->
                <el-form-item :label="nowLangue.inspectionStandardName" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input v-model="addAutoExamForm.code" :placeholder="nowLangue.pleaseImport"></el-input>
                </el-form-item>
                <!--适用检查范围-->
                <el-form-item :label="nowLangue.applicableInspectionRange" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-checkbox label="电性检验"></el-checkbox>
                    <el-checkbox label="外观检验"></el-checkbox>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.sure"></el-button>
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.cancel"></el-button>
            </div>
        </el-dialog>
        <!--修改弹窗-->
        <el-dialog :title="nowLangue.update+nowLangue.inspectionStandardName" :visible.sync="dialogUpdateVisible" size="tiny" :lock-scroll="false">
            <el-form :inline="true" :model="updateAutoExamForm" class="demo-form-inline label-minW95" style="border-bottom:1px solid #ccc;" ref="updateAutoExamForm">
                <!--法人名称-->
                <el-form-item :label="nowLangue.legalName" prop="subClassCode" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-select size="mini" clearable v-model="updateAutoExamForm.status" :placeholder="nowLangue.pleaseSelect">
                        <el-option v-for="(status,index) in statusList" :key="index" :label="status.label" :value="status.value"></el-option>
                    </el-select>
                </el-form-item>
                <!--检验标准编码-->
                <el-form-item :label="nowLangue.inspectionStandardCoding" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input v-model="updateAutoExamForm.code" disabled></el-input>
                </el-form-item>
                <!--检验标准名称-->
                <el-form-item :label="nowLangue.inspectionStandardName" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport},{ max: 50, message: nowLangue.lessThan50}]">
                    <el-input v-model="updateAutoExamForm.code" :placeholder="nowLangue.pleaseImport"></el-input>
                </el-form-item>
                <!--适用检查范围-->
                <el-form-item :label="nowLangue.applicableInspectionRange" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-checkbox label="电性检验"></el-checkbox>
                    <el-checkbox label="外观检验"></el-checkbox>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.sure"></el-button>
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.cancel"></el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
    export default {
        data() {
            return {
                nowLangue:{},
                languageScoped:{
                    zh:{
                        "pleaseSelect":"请选择",
                        "pleaseImport":"请输入",
                        "query":"查询",
                        "loadDesperately":"拼命加载中",
                        "sequence":"序",
                        "operate":"操作",
                        "update":"修改",
                        "forbidden":"禁用",
                        "enable":"启用",
                        "sure":"确定",
                        "cancel":"取消",
                        "create":"新增",
                        "legalName":"法人名称",   
                        "inspectionStandardCoding":"检验标准编码",
                        "inspectionStandardName":"检验标准名称",
                        "status":"状态",
                        "inspectionStandardDetails":"检验标准明细",
                        "applicableScope":"适用范围",
                        "founder":"创建人",
                        "creationTime":"创建时间",
                        "modifier":"修改人",
                        "latestModificationTime":"最近修改时间",
                        "applicableInspectionRange":"适用检查范围",
                        "lessThan50":"最多不能超过50个字符",
                    },
                    en:{
                        "pleaseSelect":"pleaseSelect",
                        "pleaseImport":"pleaseImport",
                        "query":"query",
                        "loadDesperately":"loadDesperately",
                        "sequence":"sequence",
                        "operate":"operate",
                        "update":"update",
                        "forbidden":"forbidden",
                        "enable":"enable",
                        "sure":"sure",
                        "cancel":"cancel",
                        "create":"create",
                        "legalName":"legalName",
                        "inspectionStandardCoding":"inspectionStandardCoding",
                        "inspectionStandardName":"inspectionStandardName",
                        "status":"status",
                        "inspectionStandardDetails":"inspectionStandardDetails",
                        "applicableScope":"applicableScope",
                        "founder":"founder",
                        "creationTime":"creationTime",
                        "modifier":"modifier",
                        "latestModificationTime":"latestModificationTime",
                        "applicableInspectionRange":"applicableInspectionRange",
                        "lessThan50":"At most not more than 50 characters"
                    }
                },
                statusList:[],   //状态下拉列表
                // 查询表单
                formInline:{

                },
                autoExamData:[{
                    name:"aaa"
                }],
                /*新增*/
                dialogAddVisible:false,//新建弹窗
                addAutoExamForm:{},//新建查询表单

                /*修改*/
                dialogUpdateVisible:false,//修改弹窗
                updateAutoExamForm:{},//新建查询表单


                //按钮禁用
                selectDisabled:false,
                addDisabled:false,
                leadInDisabled:false,
                leadOutDisabled:false,
                enableDisabled:false,
                forbiddenDisabled:false,

                loading:false,
                isPaging:true,    //是否显示分页
                pageIndex:1,    //当前页（必传）
                pageSize :10,   //每页多少条
                currentPage:1,    //当前显示3页
                currentPage3:3,
                totalNumber: 1,     //总条数
                totalPage:1    //总页数
            };
        },
        created:function(){
            this.languageType=="zh"?this.nowLangue=this.languageScoped.zh:this.nowLangue=this.languageScoped.en;
        },
        computed:{
            languageType(){
                return this.$store.state.languageType;
            }
        },
        watch:{
            languageType(){
                this.languageType=="zh"?this.nowLangue=this.languageScoped.zh:this.nowLangue=this.languageScoped.en;
            }
        },
        //进入页面立即运行此方法
        mounted: function () {
            var _this = this;
            _this.$store.commit('currentActive', 'AautoExam');
        },
        methods:{
            //查询列表
            queryClick(){
                /*var _this=this;
                 _this.loading=true;
                 var urlAddress="";
                 if(this.isClickBySelect){
                     urlAddress="projectSubstitute/queryMaterialByPage";
                 }else{
                     urlAddress="projectSubstitute/queryIncreasementMaterialByPage";
                 }
                 var tmp={
                     productLineId:_this.formInline.productLineId,
                     legalPersonCode:_this.formInline.legalPersonCode,
                     startCreateTime:_this.formInline.startCreateTime,
                     endCreateTime:_this.formInline.endCreateTime,
                     materialCode:_this.formInline.materialCode,
                     materialName:_this.formInline.materialName,
                     status:_this.formInline.status,
                     pageIndex:_this.pageIndex,
                     pageSize:_this.pageSize
                 };
                 $.ajax({
                     type: 'POST',
                     url: _this.metadata_service+urlAddress,
                     cache: false,
                     data:JSON.stringify(tmp),
                     dataType:'JSON',
                     contentType: "application/json;charset=utf-8",
                     success: function (data) {
                         if (data.success) {
                             _this.loading=false;
                             _this.isPaging=true;
                             _this.totalPage=data.data.totalPage;
                             _this.totalNumber=data.data.totalNumber;
                             _this.productData=data.data.dataList;
                         }else{
                             _this.loading=false;
                            _this.common.errorTip(data.errorMessage)
                         }
                     }
                 });*/
            },
            // 操作启用禁用
            handleStatus(index, row){
                /*var _this=this;
                if(row.status){
                    row.status = false;
                }else{
                    row.status = true;
                }
                var tmp={id: row.id,status: row.status};
                $.ajax({
                    type: 'POST',
                    url: _this.metadata_service+"materialProperty/updateStatus",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",
                    success: function (data) {
                        if (data.success) {
                            // 当前状态的显示
                            if(row.status){
                                row.statusName = _this.languageType=="zh"?' 启用':'Open';
                                var successMessage1=_this.languageType=="zh"?'启用成功！':'Open Success';
                                _this.common.successTip(successMessage1);
                            }else{
                                row.statusName = _this.languageType=="zh"?' 禁用':'Close';
                                var successMessage2=_this.languageType=="zh"?'禁用成功！':'Close Success';
                                _this.common.successTip(successMessage2);
                            }
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                });*/
            },
            handleAdd(){
              this.dialogAddVisible=true;
            },
            handleUpdate(){
                this.dialogUpdateVisible=true;
            },
            handleSizeChange(){

            },
            handleCurrentChange(){

            },
            
        }
    }
</script>



